package fr.unice.polytech.chord.core.messages.asynchronous;

import fr.unice.polytech.chord.core.ChordNode;
import fr.unice.polytech.chord.core.Key;
import fr.unice.polytech.chord.core.responses.asynchronous.ActionResponseMessage;
import fr.unice.polytech.chord.core.responses.asynchronous.AsynchronousResponseMessage;

/**
 * Removes the entry associated to the specified key when this message is
 * handled.
 * 
 * @author Anthony Parisy
 * @author Laurent Pellegrino
 * @author Marc Valdener
 * 
 * @version 10/28/2009
 */
@SuppressWarnings("serial")
public class RemoveEntryMessage extends AsynchronousMessage {

	private Key keyToUse;

	/**
	 * Constructor.
	 * 
	 * @param key
	 *            the key associated to the entry we want to remove.
	 */
	public RemoveEntryMessage(Key key) {
		this.keyToUse = key;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public AsynchronousResponseMessage handle(ChordNode node) {
		return new ActionResponseMessage(node.removeEntry(this.keyToUse));
	}
}
